package com.lzxuni.modules.qualitycomplaints.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lzxuni.common.utils.StringUtils;
import com.lzxuni.modules.common.entity.PageParameter;
import com.lzxuni.modules.productdisplay.entity.ProductDisplay;
import com.lzxuni.modules.qualitycomplaints.entity.QualityComplaints;
import com.lzxuni.modules.qualitycomplaints.mapper.QualityComplaintsMapper;
import com.lzxuni.modules.qualitycomplaints.service.QualityComplaintsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.ibatis.annotations.Insert;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 质量投诉 服务实现类
 * </p>
 *
 * @author 杨国营
 * @since 2019-07-09
 */
@Service
public class QualityComplaintsServiceImpl extends ServiceImpl<QualityComplaintsMapper, QualityComplaints> implements QualityComplaintsService {

	@Autowired
	private QualityComplaintsMapper qualityComplaintsMapper;
	@Override
	public PageInfo<QualityComplaints> queryPage(PageParameter pageParameter, String keyword) {

		if (StringUtils.isNotEmpty(pageParameter.getSidx())) {
			PageHelper.startPage(pageParameter.getPage(), pageParameter.getRows()).setOrderBy(
					pageParameter.getSidx() + " " + pageParameter.getSord());
		}else{
			PageHelper.startPage(pageParameter.getPage(), pageParameter.getRows());
		}
		List<QualityComplaints> qualityComplaintsList = qualityComplaintsMapper.selectList(new QueryWrapper<QualityComplaints>().like("product",keyword==null?"":keyword));
		PageInfo<QualityComplaints> pageInfo = new PageInfo<>(qualityComplaintsList);
		return pageInfo;
	}
}
